package com.sdcx.agrobank.ui.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.sdcx.agrobank.R;
import com.sdcx.agrobank.base.BaseFragment;
import com.sdcx.agrobank.event.xykEvent;
import com.sdcx.agrobank.ui.activity.Main3Activity;
import com.sdcx.agrobank.ui.activity.Main4Activity;
import com.sdcx.agrobank.util.GlideUtil;
import com.stx.xhb.androidx.XBanner;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;

/**
 * Project   : haveyou
 * Package    : com.sdcx.agrobank.ui.fragment
 *
 * @author : Galaxy
 * @date : 2020/11/24 10:28
 * Desc      : TODO
 **/
public class xykFragment extends BaseFragment {
    private XBanner banner1,banner2;
    private ArrayList<Object> arr,arr1;
    private ImageView xyk;

    @Override
    public void onLazyLoad() {

    }
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(xykEvent myEvent) {
        GlideUtil.display(getContext(),R.mipmap.shenqingkapian,xyk);
        xyk.setClickable(false);
        xyk.setEnabled(false);
    }
    @Override
    protected int initLayout() {
        return R.layout.xykfragment;
    }

    @Override
    protected void init(View view) {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }

        banner1 = view.findViewById(R.id.banner);
        banner2 = view.findViewById(R.id.banner1);
        xyk = view.findViewById(R.id.xyk_login);
        arr = new ArrayList<>();
        arr1 = new ArrayList<>();

        arr.add(R.mipmap.banner4);
        arr.add(R.mipmap.banner4);
        arr.add(R.mipmap.banner4);
        arr1.add(R.mipmap.tjsz3);
        arr1.add(R.mipmap.tjsz3);
        arr1.add(R.mipmap.tjsz3);
        banner1.setmAdapter(new XBanner.XBannerAdapter() {
            @Override
            public void loadBanner(XBanner banner, Object model, View view, int position) {
                //GlideUtil.display(getContext(),arr.get(position),(ImageView) view);
                Glide.with(getContext()).load(arr.get(position)).into((ImageView) view);
            }
        });
        banner1.setData(arr,null);

        banner2.setmAdapter(new XBanner.XBannerAdapter() {
            @Override
            public void loadBanner(XBanner banner, Object model, View view, int position) {
                //GlideUtil.display(getContext(),arr.get(position),(ImageView) view);
                Glide.with(getContext()).load(arr1.get(position)).into((ImageView) view);
            }
        });
        banner2.setData(arr1,null);
        xyk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getContext(), Main3Activity.class));
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initLogic() {

    }

    @Override
    public void initImmersionBar() {

    }

    @Override
    public boolean immersionBarEnabled() {
        return false;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
